SlideShare a Scribd company logo
1 of 60
#include <stdio.h>
#include <Block.h>

int main (int argc, const char * argv[]) {
   void (^add)(int, int) = ^(int i, int j) {
      printf("%d", i + j);
   };

    return 0;
}
^{
    printf("Hello world!n");
}();
int (^add)(int, int) = ^int(int i, int j) {
   return i + j;
};

printf("%dn", add(1, 1)); // 2
int (^add)(int, int) = ^int(int i, int j) {
   return i + j;
};

printf("%dn", add(1, 1)); // 2
int (^add)(int, int) = ^int(int i, int j) {
   return i + j;
};

printf("%dn", add(1, 1)); // 2
int (^add)(int, int) = ^int(int i, int j) {
   return i + j;
};

printf("%dn", add(1, 1)); // 2
^void(void) {
    printf("Hello world!n");
}();



^{
    printf("Hello world!n");
}();
int i = 100;
int (^add)(int) = ^(int j) {
   return i + j;
};

printf("%d", add(1)); // 101
i = 200;
printf("%d", add(1)); // 101
__block int i = 0;
int (^f)(int) = ^(int j) {
   i++;
   return i + j;
};

for (int index = 0; index < 10; index++) {
   printf("%d ", f(index));
} // 1 3 5 7 9 11 13 15 17 19
__block int i = 0;
int (^f)(int) = ^(int j) {
   i++;
   return i + j;
};

for (int index = 0; index < 10; index++) {
   printf("%d ", f(index));
} // 1 3 5 7 9 11 13 15 17 19
__block int i = 0;
int (^f)(int) = ^(int j) {
   i++;
   return i + j;
};

for (int index = 0; index < 10; index++) {
   printf("%d ", f(index));
} // 1 3 5 7 9 11 13 15 17 19
__block int i = 0;
int (^f)(int) = ^(int j) {
   i++;
   return i + j;
};

for (int index = 0; index < 10; index++) {
   printf("%d ", f(index));
} // 1 3 5 7 9 11 13 15 17 19
__block int i = 100;
int (^add)(int) = ^(int j) {
   return i + j;
};

printf("%d", add(1)); // 101
i = 200;
printf("%d", add(1)); // 201
__block void (^reverse)(int, int) = ^(int curt, int
max) {
   if (curt < max) {
       reverse(curt + 1, max);
   }
   printf("%d ", curt);
};

reverse(0, 10); // 10 9 8 7 6 5 4 3 2 1 0
__block void (^reverse)(int, int) = ^(int curt, int
max) {
   if (curt < max) {
       reverse(curt + 1, max);
   }
   printf("%d ", curt);
};

reverse(0, 10); // 10 9 8 7 6 5 4 3 2 1 0
__block void (^reverse)(int, int) = ^(int curt, int
max) {
   if (curt < max) {
       reverse(curt + 1, max);
   }
   printf("%d ", curt);
};

reverse(0, 10); // 10 9 8 7 6 5 4 3 2 1 0
int (^(^curried_add)(int))(int) = ^(int x) {
   return Block_copy(^(int y) {
       return x + y;
   });
};

int (^add)(int) = curried_add(1);
printf("%dn", add(1)); // 2
Block_release(add);
int (^(^curried_add)(int))(int)...




 typedef int (^IntBlock)(int);
 IntBlock (^curried_add)(int)...
typedef int (^Block)(void);

Block counter() {
   __block int i = 0;
   return Block_copy(^{
       i += 1;
       return i;
   });
}

int main (int argc, const char * argv[])
{
   Block c = counter();
   printf("%dn", c()); // 1
   printf("%dn", c()); // 2
   printf("%dn", c()); // 3
   Block_release(c);

    return 0;
}
#include <stdio.h>
#include <dispatch/dispatch.h>

int main (int argc, const char * argv[])
{
   dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT,
0), ^{
       sleep(1);
       printf("Hello world!n");
   });

    sleep(3);

    return 0;
}
#include <stdio.h>
#include <dispatch/dispatch.h>

int main (int argc, const char * argv[])
{
   dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT,
0), ^{
       sleep(1);
       printf("Hello world!n");
   });

    sleep(3);

    return 0;
}
dispatch_queue_t mq = dispatch_get_main_queue();

dispatch_queue_t gqd = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0);

dispatch_queue_t gqh = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_HIGH, 0);

dispatch_queue_t gql = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_LOW, 0);

dispatch_queue_t gqb = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_BACKGROUND, 0);

dispatch_queue_t cq = dispatch_queue_create("com.example.ConcurrentDispatchQueue",
DISPATCH_QUEUE_CONCURRENT);
dispatch_release(cq);

dispatch_queue_t sq = dispatch_queue_create("com.example.SerialDispatchQueue", DISPATCH_QUEUE_SERIAL);
dispatch_release(sq);
dispatch_async(queue,
^{
    hoge();
});
dispatch_sync(queue, ^{
    hoge();
});
dispatch_group_t group = dispatch_group_create();
dispatch_queue_t queue =
dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0);
dispatch_group_async(group, queue, ^{
    hoge();
});
dispatch_group_async(group, queue, ^{
    piyo();
});
dispatch_group_wait(group, DISPATCH_TIME_FOREVER);
dispatch_release(group);
dispatch_queue_t queue =
dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0);
dispatch_group_t group = dispatch_group_create();
dispatch_group_async(group, queue, ^{hoge(1);});
dispatch_group_async(group, queue, ^{hoge(2);});
dispatch_group_notify(group, dispatch_get_main_queue(), ^{printf("done");});
dispatch_release(group);
dispatch_time_t time =
dispatch_time(DISPATCH_TIME_NOW, 3.0 *
NSEC_PER_SEC);
dispatch_after(time, queue, ^{
    hoge();
});
dispatch_queue_t queue =
dispatch_queue_create("com.example.ConcurrentQu
eue", DISPATCH_QUEUE_CONCURRENT);
dispatch_async(queue, ^{   1});
dispatch_barrier_async(queue, ^{
    hoge();
});
dispatch_async(queue, ^{    3});
dispatch_apply(10, queue, ^(size_t index) {
    hoge(index);
});
static dispatch_once_t pred;
dispatch_once(&pred, ^{
    hoge();
});
dispatch_queue_t queue =
dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0);
dispatch_semaphore_t semaphore = dispatch_semaphore_create(1);
for (int i = 0; i < 1000; i++) {
   dispatch_async(queue, ^{
       hoge(i);
       dispatch_semaphore_wait(semaphore, DISPATCH_TIME_FOREVER);
       piyo();
       dispatch_semaphore_signal(semaphore);
   });
}
dispatch_release(semaphore);
Blocks+gcd入門
Blocks+gcd入門

More Related Content

What's hot (20)

Stl algorithm-Basic types
Stl algorithm-Basic typesStl algorithm-Basic types
Stl algorithm-Basic types
 
C++ programs
C++ programsC++ programs
C++ programs
 
C++ Programming - 1st Study
C++ Programming - 1st StudyC++ Programming - 1st Study
C++ Programming - 1st Study
 
Cquestions
Cquestions Cquestions
Cquestions
 
C++ Programming - 4th Study
C++ Programming - 4th StudyC++ Programming - 4th Study
C++ Programming - 4th Study
 
Understanding storage class using nm
Understanding storage class using nmUnderstanding storage class using nm
Understanding storage class using nm
 
งานนำเสนอ อาจารย์ลาวัลย์
งานนำเสนอ อาจารย์ลาวัลย์งานนำเสนอ อาจารย์ลาวัลย์
งานนำเสนอ อาจารย์ลาวัลย์
 
C program to implement linked list using array abstract data type
C program to implement linked list using array abstract data typeC program to implement linked list using array abstract data type
C program to implement linked list using array abstract data type
 
basic programs in C++
basic programs in C++ basic programs in C++
basic programs in C++
 
Circular queue
Circular queueCircular queue
Circular queue
 
DataStructures notes
DataStructures notesDataStructures notes
DataStructures notes
 
Basic Programs of C++
Basic Programs of C++Basic Programs of C++
Basic Programs of C++
 
BCSL 058 solved assignment
BCSL 058 solved assignmentBCSL 058 solved assignment
BCSL 058 solved assignment
 
Single linked list
Single linked listSingle linked list
Single linked list
 
Circular linked list
Circular linked listCircular linked list
Circular linked list
 
Datastructures asignment
Datastructures asignmentDatastructures asignment
Datastructures asignment
 
Martha
MarthaMartha
Martha
 
C questions
C questionsC questions
C questions
 
Function basics
Function basicsFunction basics
Function basics
 
Data Structures Using C Practical File
Data Structures Using C Practical File Data Structures Using C Practical File
Data Structures Using C Practical File
 

Viewers also liked

画像処理ライブラリ OpenCV で 出来ること・出来ないこと
画像処理ライブラリ OpenCV で 出来ること・出来ないこと画像処理ライブラリ OpenCV で 出来ること・出来ないこと
画像処理ライブラリ OpenCV で 出来ること・出来ないことNorishige Fukushima
 
最近遊んだ Wii Uの 3つのソフトの感想
最近遊んだ Wii Uの 3つのソフトの感想最近遊んだ Wii Uの 3つのソフトの感想
最近遊んだ Wii Uの 3つのソフトの感想teapipin
 
これからの時代に! パソコン離れの中のパソコン選び
これからの時代に! パソコン離れの中のパソコン選びこれからの時代に! パソコン離れの中のパソコン選び
これからの時代に! パソコン離れの中のパソコン選びteapipin
 
ツイッター調査:約173万ツイートを調査して分かったTwitterの利用動向 #twtr_hack
ツイッター調査:約173万ツイートを調査して分かったTwitterの利用動向 #twtr_hackツイッター調査:約173万ツイートを調査して分かったTwitterの利用動向 #twtr_hack
ツイッター調査:約173万ツイートを調査して分かったTwitterの利用動向 #twtr_hackteapipin
 
OpenCVをAndroidで動かしてみた
OpenCVをAndroidで動かしてみたOpenCVをAndroidで動かしてみた
OpenCVをAndroidで動かしてみた徹 上野山
 

Viewers also liked (7)

OpenCVの基礎
OpenCVの基礎OpenCVの基礎
OpenCVの基礎
 
OpenCV 3.0 on iOS
OpenCV 3.0 on iOSOpenCV 3.0 on iOS
OpenCV 3.0 on iOS
 
画像処理ライブラリ OpenCV で 出来ること・出来ないこと
画像処理ライブラリ OpenCV で 出来ること・出来ないこと画像処理ライブラリ OpenCV で 出来ること・出来ないこと
画像処理ライブラリ OpenCV で 出来ること・出来ないこと
 
最近遊んだ Wii Uの 3つのソフトの感想
最近遊んだ Wii Uの 3つのソフトの感想最近遊んだ Wii Uの 3つのソフトの感想
最近遊んだ Wii Uの 3つのソフトの感想
 
これからの時代に! パソコン離れの中のパソコン選び
これからの時代に! パソコン離れの中のパソコン選びこれからの時代に! パソコン離れの中のパソコン選び
これからの時代に! パソコン離れの中のパソコン選び
 
ツイッター調査:約173万ツイートを調査して分かったTwitterの利用動向 #twtr_hack
ツイッター調査:約173万ツイートを調査して分かったTwitterの利用動向 #twtr_hackツイッター調査:約173万ツイートを調査して分かったTwitterの利用動向 #twtr_hack
ツイッター調査:約173万ツイートを調査して分かったTwitterの利用動向 #twtr_hack
 
OpenCVをAndroidで動かしてみた
OpenCVをAndroidで動かしてみたOpenCVをAndroidで動かしてみた
OpenCVをAndroidで動かしてみた
 

Similar to Blocks+gcd入門 (20)

Cpds lab
Cpds labCpds lab
Cpds lab
 
ADA FILE
ADA FILEADA FILE
ADA FILE
 
Daapracticals 111105084852-phpapp02
Daapracticals 111105084852-phpapp02Daapracticals 111105084852-phpapp02
Daapracticals 111105084852-phpapp02
 
lets play with "c"..!!! :):)
lets play with "c"..!!! :):)lets play with "c"..!!! :):)
lets play with "c"..!!! :):)
 
C basics
C basicsC basics
C basics
 
Vcs16
Vcs16Vcs16
Vcs16
 
C++ Lambda and concurrency
C++ Lambda and concurrencyC++ Lambda and concurrency
C++ Lambda and concurrency
 
9.C Programming
9.C Programming9.C Programming
9.C Programming
 
Sorting programs
Sorting programsSorting programs
Sorting programs
 
Scala 2 + 2 > 4
Scala 2 + 2 > 4Scala 2 + 2 > 4
Scala 2 + 2 > 4
 
Program of sorting using shell sort #include stdio.h #de.pdf
 Program of sorting using shell sort  #include stdio.h #de.pdf Program of sorting using shell sort  #include stdio.h #de.pdf
Program of sorting using shell sort #include stdio.h #de.pdf
 
Lab Question
Lab QuestionLab Question
Lab Question
 
Assignment on Numerical Method C Code
Assignment on Numerical Method C CodeAssignment on Numerical Method C Code
Assignment on Numerical Method C Code
 
Ejercicios de programacion
Ejercicios de programacionEjercicios de programacion
Ejercicios de programacion
 
Function & Recursion in C
Function & Recursion in CFunction & Recursion in C
Function & Recursion in C
 
Basic c programs updated on 31.8.2020
Basic c programs updated on 31.8.2020Basic c programs updated on 31.8.2020
Basic c programs updated on 31.8.2020
 
L25-L26-Parameter passing techniques.pptx
L25-L26-Parameter passing techniques.pptxL25-L26-Parameter passing techniques.pptx
L25-L26-Parameter passing techniques.pptx
 
Code optimization
Code optimization Code optimization
Code optimization
 
Code optimization
Code optimization Code optimization
Code optimization
 
Data Structure using C
Data Structure using CData Structure using C
Data Structure using C
 

Recently uploaded

Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...apidays
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUK Journal
 
Top 10 Most Downloaded Games on Play Store in 2024
Top 10 Most Downloaded Games on Play Store in 2024Top 10 Most Downloaded Games on Play Store in 2024
Top 10 Most Downloaded Games on Play Store in 2024SynarionITSolutions
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyKhushali Kathiriya
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoffsammart93
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024The Digital Insurer
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?Igalia
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfsudhanshuwaghmare1
 
HTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation StrategiesHTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation StrategiesBoston Institute of Analytics
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
Manulife - Insurer Innovation Award 2024
Manulife - Insurer Innovation Award 2024Manulife - Insurer Innovation Award 2024
Manulife - Insurer Innovation Award 2024The Digital Insurer
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...Neo4j
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAndrey Devyatkin
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processorsdebabhi2
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century educationjfdjdjcjdnsjd
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 

Recently uploaded (20)

Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
Top 10 Most Downloaded Games on Play Store in 2024
Top 10 Most Downloaded Games on Play Store in 2024Top 10 Most Downloaded Games on Play Store in 2024
Top 10 Most Downloaded Games on Play Store in 2024
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
HTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation StrategiesHTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation Strategies
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
Manulife - Insurer Innovation Award 2024
Manulife - Insurer Innovation Award 2024Manulife - Insurer Innovation Award 2024
Manulife - Insurer Innovation Award 2024
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 

Blocks+gcd入門

  • 1.
  • 2.
  • 3.
  • 4.
  • 5.
  • 6.
  • 7.
  • 8.
  • 9.
  • 10.
  • 11.
  • 12. #include <stdio.h> #include <Block.h> int main (int argc, const char * argv[]) { void (^add)(int, int) = ^(int i, int j) { printf("%d", i + j); }; return 0; }
  • 13.
  • 14. ^{ printf("Hello world!n"); }();
  • 15. int (^add)(int, int) = ^int(int i, int j) { return i + j; }; printf("%dn", add(1, 1)); // 2
  • 16. int (^add)(int, int) = ^int(int i, int j) { return i + j; }; printf("%dn", add(1, 1)); // 2
  • 17. int (^add)(int, int) = ^int(int i, int j) { return i + j; }; printf("%dn", add(1, 1)); // 2
  • 18. int (^add)(int, int) = ^int(int i, int j) { return i + j; }; printf("%dn", add(1, 1)); // 2
  • 19. ^void(void) { printf("Hello world!n"); }(); ^{ printf("Hello world!n"); }();
  • 20. int i = 100; int (^add)(int) = ^(int j) { return i + j; }; printf("%d", add(1)); // 101 i = 200; printf("%d", add(1)); // 101
  • 21. __block int i = 0; int (^f)(int) = ^(int j) { i++; return i + j; }; for (int index = 0; index < 10; index++) { printf("%d ", f(index)); } // 1 3 5 7 9 11 13 15 17 19
  • 22. __block int i = 0; int (^f)(int) = ^(int j) { i++; return i + j; }; for (int index = 0; index < 10; index++) { printf("%d ", f(index)); } // 1 3 5 7 9 11 13 15 17 19
  • 23. __block int i = 0; int (^f)(int) = ^(int j) { i++; return i + j; }; for (int index = 0; index < 10; index++) { printf("%d ", f(index)); } // 1 3 5 7 9 11 13 15 17 19
  • 24. __block int i = 0; int (^f)(int) = ^(int j) { i++; return i + j; }; for (int index = 0; index < 10; index++) { printf("%d ", f(index)); } // 1 3 5 7 9 11 13 15 17 19
  • 25. __block int i = 100; int (^add)(int) = ^(int j) { return i + j; }; printf("%d", add(1)); // 101 i = 200; printf("%d", add(1)); // 201
  • 26. __block void (^reverse)(int, int) = ^(int curt, int max) { if (curt < max) { reverse(curt + 1, max); } printf("%d ", curt); }; reverse(0, 10); // 10 9 8 7 6 5 4 3 2 1 0
  • 27. __block void (^reverse)(int, int) = ^(int curt, int max) { if (curt < max) { reverse(curt + 1, max); } printf("%d ", curt); }; reverse(0, 10); // 10 9 8 7 6 5 4 3 2 1 0
  • 28. __block void (^reverse)(int, int) = ^(int curt, int max) { if (curt < max) { reverse(curt + 1, max); } printf("%d ", curt); }; reverse(0, 10); // 10 9 8 7 6 5 4 3 2 1 0
  • 29. int (^(^curried_add)(int))(int) = ^(int x) { return Block_copy(^(int y) { return x + y; }); }; int (^add)(int) = curried_add(1); printf("%dn", add(1)); // 2 Block_release(add);
  • 30. int (^(^curried_add)(int))(int)... typedef int (^IntBlock)(int); IntBlock (^curried_add)(int)...
  • 31. typedef int (^Block)(void); Block counter() { __block int i = 0; return Block_copy(^{ i += 1; return i; }); } int main (int argc, const char * argv[]) { Block c = counter(); printf("%dn", c()); // 1 printf("%dn", c()); // 2 printf("%dn", c()); // 3 Block_release(c); return 0; }
  • 32.
  • 33.
  • 34.
  • 35.
  • 36.
  • 37.
  • 38.
  • 39. #include <stdio.h> #include <dispatch/dispatch.h> int main (int argc, const char * argv[]) { dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{ sleep(1); printf("Hello world!n"); }); sleep(3); return 0; }
  • 40.
  • 41. #include <stdio.h> #include <dispatch/dispatch.h> int main (int argc, const char * argv[]) { dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{ sleep(1); printf("Hello world!n"); }); sleep(3); return 0; }
  • 42.
  • 43.
  • 44.
  • 45.
  • 46.
  • 47. dispatch_queue_t mq = dispatch_get_main_queue(); dispatch_queue_t gqd = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0); dispatch_queue_t gqh = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_HIGH, 0); dispatch_queue_t gql = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_LOW, 0); dispatch_queue_t gqb = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_BACKGROUND, 0); dispatch_queue_t cq = dispatch_queue_create("com.example.ConcurrentDispatchQueue", DISPATCH_QUEUE_CONCURRENT); dispatch_release(cq); dispatch_queue_t sq = dispatch_queue_create("com.example.SerialDispatchQueue", DISPATCH_QUEUE_SERIAL); dispatch_release(sq);
  • 48.
  • 50. dispatch_sync(queue, ^{ hoge(); });
  • 51. dispatch_group_t group = dispatch_group_create(); dispatch_queue_t queue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0); dispatch_group_async(group, queue, ^{ hoge(); }); dispatch_group_async(group, queue, ^{ piyo(); }); dispatch_group_wait(group, DISPATCH_TIME_FOREVER); dispatch_release(group);
  • 52. dispatch_queue_t queue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0); dispatch_group_t group = dispatch_group_create(); dispatch_group_async(group, queue, ^{hoge(1);}); dispatch_group_async(group, queue, ^{hoge(2);}); dispatch_group_notify(group, dispatch_get_main_queue(), ^{printf("done");}); dispatch_release(group);
  • 53. dispatch_time_t time = dispatch_time(DISPATCH_TIME_NOW, 3.0 * NSEC_PER_SEC); dispatch_after(time, queue, ^{ hoge(); });
  • 54. dispatch_queue_t queue = dispatch_queue_create("com.example.ConcurrentQu eue", DISPATCH_QUEUE_CONCURRENT); dispatch_async(queue, ^{ 1}); dispatch_barrier_async(queue, ^{ hoge(); }); dispatch_async(queue, ^{ 3});
  • 55. dispatch_apply(10, queue, ^(size_t index) { hoge(index); });
  • 57.
  • 58. dispatch_queue_t queue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0); dispatch_semaphore_t semaphore = dispatch_semaphore_create(1); for (int i = 0; i < 1000; i++) { dispatch_async(queue, ^{ hoge(i); dispatch_semaphore_wait(semaphore, DISPATCH_TIME_FOREVER); piyo(); dispatch_semaphore_signal(semaphore); }); } dispatch_release(semaphore);

Editor's Notes

  1. \n
  2. \n
  3. \n
  4. C&amp;#x6A19;&amp;#x6E96;&amp;#x30EF;&amp;#x30FC;&amp;#x30AD;&amp;#x30F3;&amp;#x30B0;&amp;#x30B0;&amp;#x30EB;&amp;#x30FC;&amp;#x30D7;&amp;#x306B;&amp;#x63D0;&amp;#x6848;&amp;#x3055;&amp;#x308C;&amp;#x3066;&amp;#x3044;&amp;#x307E;&amp;#x3059;&amp;#x3002;\n
  5. \n
  6. \n
  7. \n
  8. \n
  9. \n
  10. &amp;#x30B3;&amp;#x30F3;&amp;#x30D1;&amp;#x30A4;&amp;#x30EB;&amp;#x74B0;&amp;#x5883;\nclang &amp;#x306F; C&amp;#x7CFB;&amp;#x8A00;&amp;#x8A9E; &amp;#x3092;&amp;#x30BF;&amp;#x30FC;&amp;#x30B2;&amp;#x30C3;&amp;#x30C8;&amp;#x3068;&amp;#x3057;&amp;#x305F;&amp;#x30B3;&amp;#x30F3;&amp;#x30D1;&amp;#x30A4;&amp;#x30E9;&amp;#x3067;&amp;#x3001;LLVM &amp;#x4E0A;&amp;#x3067;&amp;#x52D5;&amp;#x4F5C;\n&amp;#x8A73;&amp;#x3057;&amp;#x304F;&amp;#x306F;Wikipedia&amp;#x3067;&amp;#x3002;\n
  11. \n
  12. \n
  13. \n
  14. &amp;#x3053;&amp;#x308C;&amp;#x3067;Hello world&amp;#x304C;&amp;#x51FA;&amp;#x529B;&amp;#x3055;&amp;#x308C;&amp;#x307E;&amp;#x3059;&amp;#x3002;&amp;#x30CF;&amp;#x30C3;&amp;#x30C8;&amp;#x8A18;&amp;#x53F7;&amp;#x30FB;&amp;#x6CE2;&amp;#x62EC;&amp;#x5F27;&amp;#x30FB;&amp;#x62EC;&amp;#x5F27;&amp;#x3002;&amp;#x3053;&amp;#x308C;&amp;#x306F;&amp;#x7701;&amp;#x7565;&amp;#x5F62;&amp;#x3002;\n
  15. &amp;#x5F15;&amp;#x6570;&amp;#x30FB;&amp;#x623B;&amp;#x308A;&amp;#x5024;&amp;#x3092;&amp;#x8868;&amp;#x8A18;&amp;#x3057;&amp;#x3066;&amp;#x3001;&amp;#x5909;&amp;#x6570;&amp;#x306B;&amp;#x4EE3;&amp;#x5165;&amp;#x3059;&amp;#x308B;&amp;#x3068;&amp;#x3053;&amp;#x3046;&amp;#x306A;&amp;#x308A;&amp;#x307E;&amp;#x3059;&amp;#x3002;\n
  16. &amp;#x5F15;&amp;#x6570;&amp;#x30FB;&amp;#x623B;&amp;#x308A;&amp;#x5024;&amp;#x3092;&amp;#x8868;&amp;#x8A18;&amp;#x3057;&amp;#x3066;&amp;#x3001;&amp;#x5909;&amp;#x6570;&amp;#x306B;&amp;#x4EE3;&amp;#x5165;&amp;#x3059;&amp;#x308B;&amp;#x3068;&amp;#x3053;&amp;#x3046;&amp;#x306A;&amp;#x308A;&amp;#x307E;&amp;#x3059;&amp;#x3002;\n
  17. &amp;#x5F15;&amp;#x6570;&amp;#x30FB;&amp;#x623B;&amp;#x308A;&amp;#x5024;&amp;#x3092;&amp;#x8868;&amp;#x8A18;&amp;#x3057;&amp;#x3066;&amp;#x3001;&amp;#x5909;&amp;#x6570;&amp;#x306B;&amp;#x4EE3;&amp;#x5165;&amp;#x3059;&amp;#x308B;&amp;#x3068;&amp;#x3053;&amp;#x3046;&amp;#x306A;&amp;#x308A;&amp;#x307E;&amp;#x3059;&amp;#x3002;\n
  18. &amp;#x6700;&amp;#x521D;&amp;#x306E;Hello world&amp;#x306F;&amp;#x8A73;&amp;#x7D30;&amp;#x306B;&amp;#x8A18;&amp;#x8FF0;&amp;#x3059;&amp;#x308B;&amp;#x3068;&amp;#x4E0A;&amp;#x306B;&amp;#x306A;&amp;#x308A;&amp;#x307E;&amp;#x3059;&amp;#x3002;\n
  19. i&amp;#x3092;&amp;#x30AD;&amp;#x30E3;&amp;#x30D7;&amp;#x30C1;&amp;#x30E3;&amp;#x3057;&amp;#x3066;&amp;#x307E;&amp;#x3059;&amp;#x3002;i&amp;#x3092;&amp;#x5909;&amp;#x66F4;&amp;#x3057;&amp;#x3066;&amp;#x3082;block&amp;#x306B;&amp;#x30AD;&amp;#x30E3;&amp;#x30D7;&amp;#x30C1;&amp;#x30E3;&amp;#x3055;&amp;#x308C;&amp;#x305F;&amp;#x5909;&amp;#x6570;&amp;#x306F;&amp;#x5909;&amp;#x66F4;&amp;#x3055;&amp;#x308C;&amp;#x3066;&amp;#x307E;&amp;#x305B;&amp;#x3093;&amp;#x3002;&amp;#x3061;&amp;#x306A;&amp;#x307F;&amp;#x306B;C&amp;#x8A00;&amp;#x8A9E;&amp;#x306E;&amp;#x914D;&amp;#x5217;&amp;#x306F;&amp;#x305D;&amp;#x306E;&amp;#x307E;&amp;#x307E;&amp;#x3067;&amp;#x306F;block&amp;#x306F;&amp;#x30AD;&amp;#x30E3;&amp;#x30D7;&amp;#x30C1;&amp;#x30E3;&amp;#x3067;&amp;#x304D;&amp;#x307E;&amp;#x305B;&amp;#x3093;&amp;#x3002;&amp;#x306A;&amp;#x306E;&amp;#x3067;&amp;#x30DD;&amp;#x30A4;&amp;#x30F3;&amp;#x30BF;&amp;#x3092;&amp;#x4F7F;&amp;#x7528;&amp;#x3057;&amp;#x3066;&amp;#x30AD;&amp;#x30E3;&amp;#x30D7;&amp;#x30C1;&amp;#x30E3;&amp;#x3057;&amp;#x307E;&amp;#x3059;&amp;#x3002;\n
  20. __block&amp;#x6307;&amp;#x5B9A;&amp;#x5B50;&amp;#x3092;&amp;#x4ED8;&amp;#x3051;&amp;#x308B;&amp;#x3053;&amp;#x3068;&amp;#x3067;block&amp;#x5185;&amp;#x3067;&amp;#x5909;&amp;#x6570;&amp;#x306E;&amp;#x5024;&amp;#x3092;&amp;#x5909;&amp;#x66F4;&amp;#x3059;&amp;#x308B;&amp;#x3053;&amp;#x3068;&amp;#x304C;&amp;#x51FA;&amp;#x6765;&amp;#x307E;&amp;#x3059;&amp;#x3002;\n
  21. __block&amp;#x6307;&amp;#x5B9A;&amp;#x5B50;&amp;#x3092;&amp;#x4ED8;&amp;#x3051;&amp;#x308B;&amp;#x3053;&amp;#x3068;&amp;#x3067;block&amp;#x5185;&amp;#x3067;&amp;#x5909;&amp;#x6570;&amp;#x306E;&amp;#x5024;&amp;#x3092;&amp;#x5909;&amp;#x66F4;&amp;#x3059;&amp;#x308B;&amp;#x3053;&amp;#x3068;&amp;#x304C;&amp;#x51FA;&amp;#x6765;&amp;#x307E;&amp;#x3059;&amp;#x3002;\n
  22. __block&amp;#x6307;&amp;#x5B9A;&amp;#x5B50;&amp;#x3092;&amp;#x4ED8;&amp;#x3051;&amp;#x308B;&amp;#x3053;&amp;#x3068;&amp;#x3067;block&amp;#x5185;&amp;#x3067;&amp;#x5909;&amp;#x6570;&amp;#x306E;&amp;#x5024;&amp;#x3092;&amp;#x5909;&amp;#x66F4;&amp;#x3059;&amp;#x308B;&amp;#x3053;&amp;#x3068;&amp;#x304C;&amp;#x51FA;&amp;#x6765;&amp;#x307E;&amp;#x3059;&amp;#x3002;\n
  23. __block&amp;#x304C;&amp;#x4ED8;&amp;#x304F;&amp;#x3068;&amp;#x3001;&amp;#x5143;&amp;#x306E;i&amp;#x3092;&amp;#x5909;&amp;#x66F4;&amp;#x3059;&amp;#x308B;&amp;#x3068;block&amp;#x3067;&amp;#x3082;&amp;#x5909;&amp;#x66F4;&amp;#x3055;&amp;#x308C;&amp;#x305F;&amp;#x5909;&amp;#x6570;&amp;#x304C;&amp;#x5229;&amp;#x7528;&amp;#x3055;&amp;#x308C;&amp;#x307E;&amp;#x3059;&amp;#x3002;\n
  24. block&amp;#x3092;&amp;#x518D;&amp;#x5E30;&amp;#x547C;&amp;#x3073;&amp;#x51FA;&amp;#x3057;&amp;#x3059;&amp;#x308B;&amp;#x5834;&amp;#x5408;&amp;#x306F;block&amp;#x306B;__block&amp;#x6307;&amp;#x5B9A;&amp;#x5B50;&amp;#x3092;&amp;#x4ED8;&amp;#x3051;&amp;#x307E;&amp;#x3059;\n
  25. block&amp;#x3092;&amp;#x518D;&amp;#x5E30;&amp;#x547C;&amp;#x3073;&amp;#x51FA;&amp;#x3057;&amp;#x3059;&amp;#x308B;&amp;#x5834;&amp;#x5408;&amp;#x306F;block&amp;#x306B;__block&amp;#x6307;&amp;#x5B9A;&amp;#x5B50;&amp;#x3092;&amp;#x4ED8;&amp;#x3051;&amp;#x307E;&amp;#x3059;\n
  26. block&amp;#x3092;&amp;#x8FD4;&amp;#x3059;block&amp;#x3092;&amp;#x5B9A;&amp;#x7FA9;&amp;#x3057;&amp;#x3066;&amp;#x3044;&amp;#x307E;&amp;#x3059;&amp;#x3002;&amp;#x30C7;&amp;#x30D5;&amp;#x30A9;&amp;#x30EB;&amp;#x30C8;&amp;#x3067;&amp;#x306F;&amp;#x30B9;&amp;#x30BF;&amp;#x30C3;&amp;#x30AF;&amp;#x306B;&amp;#x78BA;&amp;#x4FDD;&amp;#x3055;&amp;#x308C;&amp;#x308B;&amp;#x306E;&amp;#x3067;&amp;#x3001;&amp;#x30B9;&amp;#x30B3;&amp;#x30FC;&amp;#x30D7;&amp;#x304B;&amp;#x3089;&amp;#x51FA;&amp;#x305F;&amp;#x3089;&amp;#x958B;&amp;#x653E;&amp;#x3055;&amp;#x308C;&amp;#x3066;&amp;#x3057;&amp;#x307E;&amp;#x3044;&amp;#x307E;&amp;#x3059;&amp;#x3002;&amp;#x306E;&amp;#x3067;&amp;#x3001;Block_copy&amp;#x3067;&amp;#x30D2;&amp;#x30FC;&amp;#x30D7;&amp;#x306B;&amp;#x30B3;&amp;#x30D4;&amp;#x30FC;&amp;#x3057;&amp;#x307E;&amp;#x3059;&amp;#x3002;&amp;#x30D2;&amp;#x30FC;&amp;#x30D7;&amp;#x306B;&amp;#x30B3;&amp;#x30D4;&amp;#x30FC;&amp;#x3057;&amp;#x305F;&amp;#x3082;&amp;#x306E;&amp;#x306F;Block_release&amp;#x3067;&amp;#x958B;&amp;#x653E;&amp;#x3057;&amp;#x307E;&amp;#x3059;&amp;#x3002;Objective-C&amp;#x3060;&amp;#x3068;Block&amp;#x3092;&amp;#x30AA;&amp;#x30D6;&amp;#x30B8;&amp;#x30A7;&amp;#x30AF;&amp;#x30C8;&amp;#x3068;&amp;#x3057;&amp;#x3066;&amp;#x5229;&amp;#x7528;&amp;#x3067;&amp;#x304D;&amp;#x308B;&amp;#x306E;&amp;#x3067;&amp;#x3001;&amp;#x3061;&amp;#x3087;&amp;#x3063;&amp;#x3068;&amp;#x6271;&amp;#x3044;&amp;#x304C;&amp;#x9055;&amp;#x3063;&amp;#x3066;&amp;#x304D;&amp;#x307E;&amp;#x3059;&amp;#x3002;\n
  27. &amp;#x5206;&amp;#x304B;&amp;#x308A;&amp;#x306B;&amp;#x304F;&amp;#x3044;&amp;#x5BA3;&amp;#x8A00;&amp;#x306F;typedef&amp;#x3067;&amp;#x5206;&amp;#x304B;&amp;#x308A;&amp;#x3084;&amp;#x3059;&amp;#x304F;\n
  28. &amp;#x3068;&amp;#x3044;&amp;#x3046;&amp;#x3053;&amp;#x3068;&amp;#x3067;&amp;#x3001;&amp;#x30AB;&amp;#x30A6;&amp;#x30F3;&amp;#x30BF;&amp;#x30FC;&amp;#x3092;&amp;#x4F5C;&amp;#x3063;&amp;#x3066;&amp;#x307F;&amp;#x308B;&amp;#x3068;&amp;#x3053;&amp;#x3093;&amp;#x306A;&amp;#x3075;&amp;#x3046;&amp;#x306B;&amp;#x306A;&amp;#x308A;&amp;#x307E;&amp;#x3059;&amp;#x3002;\nBlocks&amp;#x3092;&amp;#x4F7F;&amp;#x3046;&amp;#x3053;&amp;#x3068;&amp;#x3067;&amp;#x30B3;&amp;#x30FC;&amp;#x30C7;&amp;#x30A3;&amp;#x30F3;&amp;#x30B0;&amp;#x304C;&amp;#x4E00;&amp;#x5909;&amp;#x3057;&amp;#x307E;&amp;#x3059;&amp;#x3002;&amp;#x305C;&amp;#x3072;&amp;#x4F7F;&amp;#x3063;&amp;#x3066;&amp;#x307F;&amp;#x3066;&amp;#x304F;&amp;#x3060;&amp;#x3055;&amp;#x3044;&amp;#x3002;\n
  29. \n
  30. &amp;#x30E9;&amp;#x30A4;&amp;#x30BB;&amp;#x30F3;&amp;#x30B9;&amp;#x306F;Apache 2.0&amp;#x3067;&amp;#x3059;&amp;#x3002;FreeBSD&amp;#x306B;&amp;#x3082;&amp;#x30DD;&amp;#x30FC;&amp;#x30C6;&amp;#x30A3;&amp;#x30F3;&amp;#x30B0;&amp;#x3055;&amp;#x308C;&amp;#x307E;&amp;#x3057;&amp;#x305F;&amp;#x3002;\n
  31. &amp;#x30BF;&amp;#x30B9;&amp;#x30AF;&amp;#x3092;&amp;#x975E;&amp;#x540C;&amp;#x671F;&amp;#x306B;&amp;#x5B9F;&amp;#x884C;&amp;#x3059;&amp;#x308B;&amp;#x6280;&amp;#x8853;\n
  32. \n
  33. \n
  34. &amp;#x30AD;&amp;#x30E5;&amp;#x30FC;&amp;#x306B;&amp;#x5165;&amp;#x308C;&amp;#x305F;&amp;#x30BF;&amp;#x30B9;&amp;#x30AF;&amp;#x304C;&amp;#x3069;&amp;#x3046;&amp;#x306A;&amp;#x308B;&amp;#x304B;&amp;#x3002;\n&amp;#x30D7;&amp;#x30ED;&amp;#x30B0;&amp;#x30E9;&amp;#x30DE;&amp;#x304C;&amp;#x30B9;&amp;#x30EC;&amp;#x30C3;&amp;#x30C9;&amp;#x3092;&amp;#x7528;&amp;#x610F;&amp;#x3057;&amp;#x305F;&amp;#x308A;&amp;#x30AD;&amp;#x30E5;&amp;#x30FC;&amp;#x3068;&amp;#x30BF;&amp;#x30B9;&amp;#x30AF;&amp;#x3092;&amp;#x7BA1;&amp;#x7406;&amp;#x3057;&amp;#x305F;&amp;#x308A;&amp;#x3059;&amp;#x308B;&amp;#x5FC5;&amp;#x8981;&amp;#x304C;&amp;#x6709;&amp;#x308A;&amp;#x307E;&amp;#x305B;&amp;#x3093;&amp;#x3002;\n&amp;#x30B7;&amp;#x30B9;&amp;#x30C6;&amp;#x30E0;&amp;#x30EC;&amp;#x30D9;&amp;#x30EB;&amp;#x3067;&amp;#x7BA1;&amp;#x7406;&amp;#x3059;&amp;#x308B;&amp;#x3053;&amp;#x3068;&amp;#x3067;&amp;#x3001;CPU&amp;#x306E;&amp;#x30B3;&amp;#x30A2;&amp;#x6570;&amp;#x306B;&amp;#x5408;&amp;#x308F;&amp;#x305B;&amp;#x3066;&amp;#x30B9;&amp;#x30EC;&amp;#x30C3;&amp;#x30C9;&amp;#x304C;&amp;#x4F5C;&amp;#x6210;&amp;#x3055;&amp;#x308C;&amp;#x307E;&amp;#x3059;&amp;#x3002;&amp;#x306A;&amp;#x306E;&amp;#x3067;&amp;#x3001;&amp;#x52B9;&amp;#x7387;&amp;#x826F;&amp;#x304F;&amp;#x5B9F;&amp;#x884C;&amp;#x3055;&amp;#x308C;&amp;#x307E;&amp;#x3059;&amp;#x3002;\nGCD&amp;#x306F;&amp;#x7A7A;&amp;#x3044;&amp;#x305F;&amp;#x30B9;&amp;#x30EC;&amp;#x30C3;&amp;#x30C9;&amp;#x3092;&amp;#x81EA;&amp;#x52D5;&amp;#x7684;&amp;#x306B;&amp;#x518D;&amp;#x5229;&amp;#x7528;&amp;#x3057;&amp;#x307E;&amp;#x3059;&amp;#x3002;\n
  35. Mac OS X&amp;#x3084;FreeBSD&amp;#x3067;&amp;#x306F;&amp;#x30AB;&amp;#x30FC;&amp;#x30CD;&amp;#x30EB;&amp;#x30EC;&amp;#x30D9;&amp;#x30EB;&amp;#x3067;&amp;#x5B9F;&amp;#x88C5;&amp;#x3055;&amp;#x308C;&amp;#x3066;&amp;#x3044;&amp;#x307E;&amp;#x3059;&amp;#x304C;&amp;#x3001;Debian/Ubuntu&amp;#x3067;&amp;#x306F;&amp;#x305D;&amp;#x3046;&amp;#x3067;&amp;#x306F;&amp;#x306A;&amp;#x3044;&amp;#x3088;&amp;#x3046;&amp;#x3067;&amp;#x3059;&amp;#x3002;\n
  36. \n
  37. \n
  38. \n
  39. Serial&amp;#x306F;&amp;#x9806;&amp;#x6B21;&amp;#x3001;Concurrent&amp;#x306F;&amp;#x540C;&amp;#x6642;&amp;#x767A;&amp;#x751F;&amp;#x3068;&amp;#x3044;&amp;#x3046;&amp;#x610F;&amp;#x5473;\n
  40. \n
  41. \n
  42. &amp;#x9AD8;&amp;#x512A;&amp;#x5148;&amp;#x5EA6;&amp;#x3001; &amp;#x6A19;&amp;#x6E96;&amp;#x512A;&amp;#x5148;&amp;#x5EA6;&amp;#x3001;&amp;#x4F4E;&amp;#x512A;&amp;#x5148;&amp;#x5EA6;&amp;#x3001;&amp;#x30CF;&amp;#x3099;&amp;#x30C3;&amp;#x30AF;&amp;#x30AF;&amp;#x3099;&amp;#x30E9;&amp;#x30A6;&amp;#x30F3;&amp;#x30C8;&amp;#x3099;&amp;#x512A;&amp;#x5148;&amp;#x5EA6;&amp;#x306E;4&amp;#x3064;&amp;#x306E;&amp;#x512A;&amp;#x5148;&amp;#x5EA6;&amp;#x304C;&amp;#x3042;&amp;#x308A;&amp;#x307E;&amp;#x3059;&amp;#x3002;&amp;#x305F;&amp;#x3060;&amp;#x3057;&amp;#x3001;GCD&amp;#x306F;&amp;#x30EA;&amp;#x30A2;&amp;#x30EB;&amp;#x30BF;&amp;#x30A4;&amp;#x30E0;&amp;#x3068;&amp;#x3044;&amp;#x3046;&amp;#x308F;&amp;#x3051;&amp;#x3067;&amp;#x306F;&amp;#x306A;&amp;#x3044;&amp;#x306E;&amp;#x3067;&amp;#x76EE;&amp;#x5B89;&amp;#x306B;&amp;#x904E;&amp;#x304E;&amp;#x307E;&amp;#x305B;&amp;#x3093;&amp;#x3002;\n\n
  43. dispatch_retain&amp;#x3084;dispatch_release&amp;#x3092;Main&amp;#x30AD;&amp;#x30E5;&amp;#x30FC;&amp;#x3084;&amp;#x30B0;&amp;#x30ED;&amp;#x30FC;&amp;#x30D0;&amp;#x30EB;&amp;#x30AD;&amp;#x30E5;&amp;#x30FC;&amp;#x306B;&amp;#x884C;&amp;#x3063;&amp;#x3066;&amp;#x3082;&amp;#x3001;&amp;#x4F55;&amp;#x3082;&amp;#x8D77;&amp;#x304D;&amp;#x307E;&amp;#x305B;&amp;#x3093;&amp;#x3002;\ndispatch_set_target_queue&amp;#x3067;Dispatch Queue&amp;#x306E;&amp;#x5B9F;&amp;#x884C;&amp;#x968E;&amp;#x5C64;&amp;#x3092;&amp;#x4F5C;&amp;#x308B;&amp;#x3053;&amp;#x3068;&amp;#x3082;&amp;#x53EF;&amp;#x80FD;&amp;#x3067;&amp;#x3059;&amp;#x3002;\n
  44. \n
  45. \n
  46. \n
  47. &amp;#x30C7;&amp;#x30C3;&amp;#x30C9;&amp;#x30ED;&amp;#x30C3;&amp;#x30AF;&amp;#x306B;&amp;#x6CE8;&amp;#x610F;&amp;#x304C;&amp;#x5FC5;&amp;#x8981;&amp;#x3067;&amp;#x3059;&amp;#x3002;&amp;#x305F;&amp;#x3068;&amp;#x3048;&amp;#x3070;&amp;#x30E1;&amp;#x30A4;&amp;#x30F3;&amp;#x30B9;&amp;#x30EC;&amp;#x30C3;&amp;#x30C9;&amp;#x304B;&amp;#x3089;&amp;#x30E1;&amp;#x30A4;&amp;#x30F3;&amp;#x30B9;&amp;#x30EC;&amp;#x30C3;&amp;#x30C9;&amp;#x30AD;&amp;#x30E5;&amp;#x30FC;&amp;#x306B;dispatch_sync&amp;#x3067;&amp;#x30D6;&amp;#x30ED;&amp;#x30C3;&amp;#x30AF;&amp;#x3092;&amp;#x767B;&amp;#x9332;&amp;#x3059;&amp;#x308B;&amp;#x3068;&amp;#x3001;&amp;#x30C7;&amp;#x30C3;&amp;#x30C9;&amp;#x30ED;&amp;#x30C3;&amp;#x30AF;&amp;#x306B;&amp;#x306A;&amp;#x308A;&amp;#x307E;&amp;#x3059;&amp;#x3002;\n
  48. &amp;#x30AB;&amp;#x30EC;&amp;#x30F3;&amp;#x30C8;&amp;#x30B9;&amp;#x30EC;&amp;#x30C3;&amp;#x30C8;&amp;#x3099;&amp;#x306F;&amp;#x505C;&amp;#x6B62;&amp;#x3055;&amp;#x308C;&amp;#x3001;&amp;#x30B0;&amp;#x30EB;&amp;#x30FC;&amp;#x30D7;&amp;#x5316;&amp;#x3055;&amp;#x308C;&amp;#x305F;&amp;#x30BF;&amp;#x30B9;&amp;#x30AF;&amp;#x306E;&amp;#x5B9F;&amp;#x884C;&amp;#x304C;&amp;#x7D42;&amp;#x4E86;&amp;#x3059;&amp;#x308B;&amp;#x306E;&amp;#x3092;&amp;#x5F85;&amp;#x3061;&amp;#x307E;&amp;#x3059;&amp;#x3002;&amp;#x5F85;&amp;#x3061;&amp;#x6642;&amp;#x9593;&amp;#x306F;dispatch_group_wait&amp;#x306E;dispatch_time_t&amp;#x578B;&amp;#x306E;&amp;#x4E8C;&amp;#x3064;&amp;#x76EE;&amp;#x306E;&amp;#x5F15;&amp;#x6570;&amp;#x3067;&amp;#x6307;&amp;#x5B9A;&amp;#x3057;&amp;#x307E;&amp;#x3059;&amp;#x3002;DISPATCH_TIME_FOREVER&amp;#x3067;&amp;#x6C38;&amp;#x9060;&amp;#x306B;&amp;#x5F85;&amp;#x3061;&amp;#x307E;&amp;#x3059;&amp;#x304C;&amp;#x3001;&amp;#x6642;&amp;#x9593;&amp;#x3092;&amp;#x6307;&amp;#x5B9A;&amp;#x3059;&amp;#x308B;&amp;#x3053;&amp;#x3068;&amp;#x304C;&amp;#x51FA;&amp;#x6765;&amp;#x307E;&amp;#x3059;&amp;#x3002;\ndispatch_group_wait&amp;#x306F;&amp;#x623B;&amp;#x308A;&amp;#x5024;&amp;#x304C;&amp;#x3042;&amp;#x3063;&amp;#x3066;&amp;#x3001;0&amp;#x3067;&amp;#x3059;&amp;#x3079;&amp;#x3066;&amp;#x306E;&amp;#x51E6;&amp;#x7406;&amp;#x304C;&amp;#x5B8C;&amp;#x4E86;&amp;#x3001;0&amp;#x4EE5;&amp;#x5916;&amp;#x3060;&amp;#x3068;&amp;#x307E;&amp;#x3060;&amp;#x5B9F;&amp;#x884C;&amp;#x4E2D;&amp;#x3092;&amp;#x8868;&amp;#x3057;&amp;#x307E;&amp;#x3059;&amp;#x3002;DISPATCH_TIME_NOW&amp;#x3092;&amp;#x6E21;&amp;#x3059;&amp;#x3068;&amp;#x3001;&amp;#x3059;&amp;#x3050;&amp;#x306B;&amp;#x5B9F;&amp;#x884C;&amp;#x72B6;&amp;#x614B;&amp;#x3092;&amp;#x8ABF;&amp;#x3079;&amp;#x3089;&amp;#x308C;&amp;#x307E;&amp;#x3059;&amp;#x3002;\n
  49. &amp;#x3053;&amp;#x306E;&amp;#x5834;&amp;#x5408;&amp;#x3001;&amp;#x7D42;&amp;#x4E86;&amp;#x3092;&amp;#x5F85;&amp;#x3061;&amp;#x307E;&amp;#x305B;&amp;#x3093;&amp;#x3002;\n
  50. &amp;#x30EA;&amp;#x30A2;&amp;#x30EB;&amp;#x30BF;&amp;#x30A4;&amp;#x30E0;&amp;#x6027;&amp;#x306F;&amp;#x306A;&amp;#x3044;&amp;#x306E;&amp;#x3067;&amp;#x3001;3&amp;#x79D2;&amp;#x304F;&amp;#x3089;&amp;#x3044;&amp;#x5F8C;&amp;#x306B;&amp;#x30AD;&amp;#x30E5;&amp;#x30FC;&amp;#x306B;&amp;#x8FFD;&amp;#x52A0;&amp;#x3055;&amp;#x308C;&amp;#x3001;&amp;#x4ED6;&amp;#x306B;&amp;#x30BF;&amp;#x30B9;&amp;#x30AF;&amp;#x304C;&amp;#x767B;&amp;#x9332;&amp;#x3055;&amp;#x308C;&amp;#x3066;&amp;#x3044;&amp;#x308C;&amp;#x3070;&amp;#x3001;&amp;#x5B9F;&amp;#x884C;&amp;#x3055;&amp;#x308C;&amp;#x308B;&amp;#x30BF;&amp;#x30A4;&amp;#x30DF;&amp;#x30F3;&amp;#x30B0;&amp;#x306F;&amp;#x3055;&amp;#x3089;&amp;#x306B;&amp;#x9045;&amp;#x304F;&amp;#x306A;&amp;#x308B;&amp;#x3068;&amp;#x8003;&amp;#x3048;&amp;#x3066;&amp;#x304F;&amp;#x3060;&amp;#x3055;&amp;#x3044;&amp;#x3002;\n
  51. dispatch_barrier_sync&amp;#x3068;&amp;#x3044;&amp;#x3046;&amp;#x95A2;&amp;#x6570;&amp;#x3082;&amp;#x3042;&amp;#x308A;&amp;#x307E;&amp;#x3059;&amp;#x3002;\n
  52. &amp;#x305D;&amp;#x308C;&amp;#x305E;&amp;#x308C;&amp;#x306E;&amp;#x30BF;&amp;#x30B9;&amp;#x30AF;&amp;#x306F;&amp;#x4E26;&amp;#x5217;&amp;#x306B;&amp;#x5B9F;&amp;#x884C;&amp;#x3055;&amp;#x308C;&amp;#x307E;&amp;#x3059;&amp;#x304C;&amp;#x3001;&amp;#x3059;&amp;#x3079;&amp;#x3066;&amp;#x306E;&amp;#x51E6;&amp;#x7406;&amp;#x304C;&amp;#x7D42;&amp;#x4E86;&amp;#x3059;&amp;#x308B;&amp;#x307E;&amp;#x3067;&amp;#x5F85;&amp;#x3061;&amp;#x307E;&amp;#x3059;&amp;#x3002;\n
  53. \n
  54. &amp;#x30AD;&amp;#x30E5;&amp;#x30FC;&amp;#x306E;suspend&amp;#x3068;resume&amp;#x3092;&amp;#x884C;&amp;#x3048;&amp;#x307E;&amp;#x3059;&amp;#x3002;\nDispatch I/O&amp;#x3067;&amp;#x8907;&amp;#x6570;&amp;#x306E;&amp;#x30B9;&amp;#x30EC;&amp;#x30C3;&amp;#x30C8;&amp;#x3099;&amp;#x3092;&amp;#x4F7F;&amp;#x3063;&amp;#x3066;&amp;#x4E26;&amp;#x5217;&amp;#x306B;&amp;#x8AAD;&amp;#x307F;&amp;#x8FBC;&amp;#x3080;&amp;#x3002;\n&amp;#x30BB;&amp;#x30DE;&amp;#x30D5;&amp;#x30A9;&amp;#x3067;&amp;#x6392;&amp;#x4ED6;&amp;#x5236;&amp;#x5FA1;&amp;#x3002;\nDispatch Source&amp;#x306F;kqueue&amp;#x306E;&amp;#x30E9;&amp;#x30C3;&amp;#x30D1;&amp;#x30FC;&amp;#x3002;\n
  55. \n
  56. \n
  57. \n